From: Alexander Sedov <alex0player@gmail.com>
Date: Sun, 14 Apr 2013 20:12:10 +0000 (+0400)
Subject: Got rid of code duplication in tnew() and tresize().
X-Git-Url: https://git.owens.tech/assets/lich_lifts_title_slice.png%20%22Lich%20Lifts%22/assets/lich_lifts_title_slice.png%20%22Lich%20Lifts%22/git?a=commitdiff_plain;h=fed9968ba5d3c6874f73517b261968746d36801e;p=st.git

Got rid of code duplication in tnew() and tresize().

Signed-off-by: Christoph Lohmann <20h@r-36.net>
---

diff --git a/st.c b/st.c
index 56dc94c..fc07a46 100644
--- a/st.c
+++ b/st.c
@@ -1195,22 +1195,10 @@ treset(void) {
 
 void
 tnew(int col, int row) {
-	/* set screen size */
-	term.row = row;
-	term.col = col;
-	term.line = xmalloc(term.row * sizeof(Line));
-	term.alt  = xmalloc(term.row * sizeof(Line));
-	term.dirty = xmalloc(term.row * sizeof(*term.dirty));
-	term.tabs = xmalloc(term.col * sizeof(*term.tabs));
-
-	for(row = 0; row < term.row; row++) {
-		term.line[row] = xmalloc(term.col * sizeof(Glyph));
-		term.alt [row] = xmalloc(term.col * sizeof(Glyph));
-		term.dirty[row] = 0;
-	}
-
+	/* setting "zero" terminal to resize it later */
+	memset(&term, 0, sizeof(Term));
+	tresize(col, row);
 	term.numlock = 1;
-	memset(term.tabs, 0, term.col * sizeof(*term.tabs));
 	/* setup screen */
 	treset();
 }